<?php defined('IN_KG') or exit('Access Invalid!');?>

<link rel="stylesheet" href="/data/resource/layui/layui.all.js">
<link rel="stylesheet" href="/data/resource/layui/css/layui.css">

<div class="tabmenu">
    <ul class="tab pngFix">
        <li class="active"><a href="http://192.168.229.138:99/index.php?control=store_groupbuy&amp;op=groupbuy_list">订金列表</a></li></ul>
</div>

<table class="ncsc-default-table">
    <thead>
        <th>订单ID</th>
        <th>订单编号</th>
        <th>订金</th>
        <th>买家姓名</th>
        <th>订单状态</th>
        <th>添加时间</th>
        <th>操作</th>
    </thead>

    <?php foreach ($output['order'] as $item => $value){?>
        <tr>
            <td><?php echo $value['order_id'];?></td>
            <td>
                <a href="/index.php?control=store_order&op=show_order&order_id=<?php echo $value['order_id'];?>">
                    <?php echo $value['goods_info']['goods_spec']?>
                </a>
            </td>
            <td><?php echo $value['order_amount'];?></td>
            <td><?php echo $value['buyer_name'];?> (<?php echo $value['buyer_id'];?>) </td>
            <td>
                <?php if ($value['order_state'] == 0){echo '已取消';}?>
                <?php if ($value['order_state'] == 10){echo '未支付';}?>
                <?php if ($value['order_state'] == 20){echo '已支付';}?>
                <?php if ($value['order_state'] == 30){echo '已发货';}?>
                <?php if ($value['order_state'] == 40){echo '已收货';}?>
            </td>
            <td><?php echo date('Y-m-d H:i:s',$value['add_time']);?></td>
            <td>
                <?php if ($value['order_state'] == ORDER_STATE_PAY){?>
                    <a href="#" onclick="cancel_order(<?php echo $value['order_id']?>)">取消订单</a>
                <?php }?>
            </td>
        </tr>
    <?php }?>
</table>


<script>
    function cancel_order(order_id){
        var status = confirm("是否确定取消该订单，取消该订单将会进行退款处理");
        if(status == false){
            return false;
        }
        $.post("/index.php?control=store_groupbuy&op=gruopbuy_order_cancel",{'order_id':order_id},function(result){
            if(result.code == 200){
                alert(result.msg);
                window.location.reload();
            }else{
                alert(result.msg);
            }
        },'json');
    }
</script>